<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">FBA库存数据监控</h3></div>
            <div class="panel-body">
                <form action="__URL__/fbaInventory" method="get" id="form" onsubmit="return check()">
                    <div class="container-fluid">

                        <div class="col-sm-12 col-md-6  add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">日期</span>
                                <input class="form-control form-date_1" type="text" name="claim_arrive_time_from" value="{$_GET['claim_arrive_time_from']}" style="cursor:pointer;" readonly>
                                <span class="input-group-addon"><span class="icon-calendar"></span></span>
                                <input class="form-control form-date_1" type="text" name="claim_arrive_time_to" value="{$_GET['claim_arrive_time_to']}" style="cursor:pointer;" readonly>
                                <span class="input-group-addon fix-border fix-padding">&nbsp;<span class="text-danger">0</span>天</span>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6 add-space">
                        <input class="btn btn-primary" type="submit" value="搜索">
                        <input class="btn btn-default" type="reset" value="重置">
                        <input class="btn btn-warning" type="button" onclick="downloadFba()" value="导出明细">
                    </div>
                </form>
                <table class="table table-striped  table-hover" cellspacing="0" width="100%">
                    <thead>
                    <tr style="align-content: center">
                        <th></th>
                        <th colspan="3" class="text-center">采购在途</th>
                        <th colspan="3" class="text-center">中转仓</th>
                        <th colspan="3" class="text-center">国际运输在途</th>
                        <th colspan="3" class="text-center">各站点库存汇总</th>
                        <th colspan="2" class="text-center">合计</th>
                    </tr>
                    <tr>
                        <th>日期</th>
                        <th>sku款数</th>
                        <th>PCS</th>
                        <th>金额(元)</th>
                        <th>sku款数</th>
                        <th>PCS</th>
                        <th>金额(元)</th>
                        <th>sku款数</th>
                        <th>PCS</th>
                        <th>金额(元)</th>
                        <th>sku款数</th>
                        <th>PCS</th>
                        <th>金额(元)</th>
                        <th>总PCS</th>
                        <th>总金额(元)</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="data" id="val">
                        <tr>
                            <td>{$val.date}</td>
                            <td>{$val.cg_sku}</td>
                            <td>{$val.cg_pcs}</td>
                            <td>{$val.cg_money}</td>
                            <td>{$val.zzc_sku}</td>
                            <td>{$val.zzc_pcs}</td>
                            <td>{$val.zzc_money}</td>
                            <td>{$val.gjzt_sku}</td>
                            <td>{$val.gjzt_pcs}</td>
                            <td>{$val.gjzt_money}</td>
                            <td>{$val.hz_sku}</td>
                            <td>{$val.hz_pcs}</td>
                            <td>{$val.hz_money}</td>
                            <td>{$val.all_pcs}</td>
                            <td>{$val.all_money}</td>
                        </tr>
                    </volist>

                </table>
                <div class="row">
                    <div class="col-md-6" id="container1" style="border:1px solid #ccc; margin-bottom:20px;"></div>
                    <div class="col-md-6" id="container2" style="border:1px solid #ccc; margin-bottom:20px;"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/yksui/js/chart/highcharts.js"></script>
<script>
    $('.form-date_1').datetimepicker({
        lang:'ch',
        timepicker:false,
        format:'Y-m-d',
        formatDate:'Y-m-d'
    });
    function check() {
        var start_time = Date.parse($("input[name=claim_arrive_time_from]").val());
        var end_time   = Date.parse($("input[name=claim_arrive_time_to]").val());
        var diff       = end_time-start_time;                         //时间差的毫秒数
        var days=Math.floor(diff/(24*3600*1000));
        if(days >=0){
            return true;
        }else if($("input[name=claim_arrive_time_from]").val()=='' && $("input[name=claim_arrive_time_to]").val()==''){
            return true;
        }else{
            layer.msg('日期填写错误', {icon: 5});
            return false;
        }

    }
    function downloadFba() {
        var data = $('#form').serialize();
        window.location.href="__URL__/fbaInventory?down=ok&"+data;
    }
    $(function () {
        var url = $('#form').serialize();
        $.get("__URL__/fbaInventory?api=ok&"+url,
            function(data){
                allChart = eval("("+data+")");
                all_day           = allChart.dateDay;
                report_money      = allChart.all_money;
                report_pcs        = allChart.all_quantity;
                highChart();
            });
    });
    function highChart() {
        $('#container1').highcharts({
            chart: {
                zoomType: 'xy'
            },
            title: {
                text: '总金额曲线图(元)'
            },
            subtitle: {
                text: ''
            },
            xAxis: [{
                categories: all_day
            }],
            yAxis: [{ // Primary yAxis
                labels: {
                    format: '￥{value}',
                    style: {
                        color: '#89A54E'
                    }
                },
                title: {
                    text: '',
                    style: {
                        color: '#89A54E'
                    }
                }
            }],
            tooltip: {
                shared: true
            },
            series: [ {
                name: '总金额',
                color: '#89A54E',
                type: 'spline',
                data: report_money,
                tooltip: {
                    valueSuffix: '元'
                },
                dataLabels: {
                    enabled: false,
                    rotation: -45,
                    color: '#000000'
                }
            }]
        });
        $('#container2').highcharts({
            chart: {
                zoomType: 'xy'
            },
            title: {
                text: '总PCS曲线图'
            },
            subtitle: {
                text: ''
            },
            xAxis: [{
                categories: all_day
            }],
            yAxis: [{ // Primary yAxis
                labels: {
                    format: '{value}',
                    style: {
                        color: '#89A54E'
                    }
                },
                title: {
                    text: '',
                    style: {
                        color: '#89A54E'
                    }
                }
            }],
            tooltip: {
                shared: true
            },
            series: [ {
                name: '总PCS',
                color: '#89A54E',
                type: 'spline',
                data: report_pcs,
                tooltip: {
                    valueSuffix: ''
                },
                dataLabels: {
                    enabled: false,
                    rotation: -45,
                    color: '#000000'
                }
            }]
        });
    }
</script>





